Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

runes2

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

runes2

Unicode-aware JS string splitting, typescript version

  • 0.4.16
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
135K
increased by28.5%
Maintainers
1
Weekly downloads
 
Created
Source

✂️ Runes

Unicode-aware JS string splitting with full Emoji support.

Split a string into its constituent characters, without munging emoji and other non-BMP code points.

this is typescript version fork form runes

Why?

The native String#split implementation does not pay attention to surrogate pairs. When the code units of a surrogate pair are split apart, they are not intelligible on their own. Unless they are put back together in the correct order, individual code units will cause problems in code that handles strings.

Installation

$ npm install runes2

Example

const runes = require('runes2')
const runes = require('runes2').runes
import runes from 'runes2';
import * as runes from 'runes2';
// Standard String.split
'♥️'.split('') // => ['♥', '️']
'Emoji 🤖'.split('') // => ['E', 'm', 'o', 'j', 'i', ' ', '�', '�']
'👩‍👩‍👧‍👦'.split('') // => ['�', '�', '‍', '�', '�', '‍', '�', '�', '‍', '�', '�']

// ES6 string iterator
[...'♥️'] => [ '♥', '️' ]
[...'Emoji 🤖'] // => [ 'E', 'm', 'o', 'j', 'i', ' ', '🤖' ]
[...'👩‍👩‍👧‍👦'] // => [ '👩', '', '👩', '', '👧', '', '👦' ]

// Runes
runes('♥️') // => ['♥️']
runes('Emoji 🤖') // => ['E', 'm', 'o', 'j', 'i', ' ', '🤖']
runes('👩‍👩‍👧‍👦') // => ['👩‍👩‍👧‍👦']

Substring example

// String.substring
'👨‍👨‍👧‍👧a'.substring(1) // => '�‍👨‍👧‍👧a'

// Runes
runes.substr('👨‍👨‍👧‍👧a', 1) // => 'a'

Keywords

FAQs

Package last updated on 17 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc